home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-04-21 | 2.5 KB | 90 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWMemTas.h
- // Release Version: $ 1.0d1 $
- //
- // Creation Date: 3/28/94
- //
- // Copyright: © 1994 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #ifndef FWMEMTAS_H
- #define FWMEMTAS_H
-
- #ifndef FWPRITAS_H
- #include "FWPriTas.h"
- #endif
-
- #ifndef FWMEMMGR_H
- #include "FWMemMgr.h"
- #endif
-
- //========================================================================================
- // Forward class declarations
- //========================================================================================
-
- class FW_CMemoryHeap;
-
- //========================================================================================
- // Struct FW_SPrivMemoryGlobals
- //========================================================================================
-
- struct FW_SPrivMemoryGlobals
- {
- FW_CMemoryHeap* gMemoryHeap; // The heap
- FW_PFVV gNewHandler; // The new handler
- unsigned long gLastRequested; // The last requested block size
- #ifdef FW_qUsePlatformAlloc
- short gInitialized;
- // gInitialized is necessary for this qUsePlatformAlloc case as
- // a replacement for giving gMemoryHeap a nonzero value.
- #endif
- };
-
- //========================================================================================
- // CLASS FW_CMemoryTaskGlobals
- //========================================================================================
-
- class FW_CMemoryTaskGlobals
- {
- public:
- static FW_SPrivMemoryGlobals& GetMemoryGlobals();
-
- static void SetMemoryHeap(FW_CMemoryHeap* aMemoryHeap);
-
- static void Initialize(FW_SPrivMemoryGlobals& memGlobals);
- static void Terminate();
-
- static void InitializeMemoryHeap(FW_SPrivMemoryGlobals& memGlobals);
- static void TerminateMemoryHeap();
-
- private:
-
- enum {kMemoryGlobalsOffset = 126};
-
- FW_CMemoryTaskGlobals();
- };
-
-
- //----------------------------------------------------------------------------------------
- // FW_CMemoryTaskGlobals::GetMemoryGlobals
- //----------------------------------------------------------------------------------------
-
- inline FW_SPrivMemoryGlobals& FW_CMemoryTaskGlobals::GetMemoryGlobals()
- {
- FW_SPrivMemoryGlobals *globals = (FW_SPrivMemoryGlobals*)
- FW_CPrivTaskGlobals::GetTaskGlobals(kMemoryGlobalsOffset);
- FW_PRIV_ASSERT(globals != 0);
- #ifdef FW_qUsePlatformAlloc
- if (globals->gInitialized == 0)
- Initialize(*globals);
- #else
- if (globals->gMemoryHeap == 0)
- Initialize(*globals);
- #endif
- return *globals;
- }
-
- #endif
-